package com.equipment;

import com.util.EncodingUtil;

/**
 * A8指令释放OBU
 * @version 1.18
 * @author 刘亚东
 */
public class CloseOBUConnectionRequest {


	private String STX = "55AA"; // 帧开始标志
	private String RSCTL = "00"; // 串口帧序列号
	private String Length = ""; // 数据长度
	private String code = "FD"; // 代码
	private String broadening = "A8"; // 扩展代码
	private String Type="";	//0表示交易成功释放，1表示交易异常释放

	private String BCC = ""; // 异或校验值

	/**
	 * 发送激活OBU请求幀
	 *
	 * @return
	 */
	public String command(String type) {
		this.Type=EncodingUtil.desToHex(Integer.parseInt(type), 2);
		// 计算出长度转16进制(位数不够补0)
		Length = EncodingUtil.desToHex((broadening+Type).length() / 2, 4);
		String DATA = RSCTL + Length + code + broadening + Type;
		// 异或校验从RSCTL到DATA所有字节的异或值
		BCC = EncodingUtil.yihuo(EncodingUtil.change(DATA));
		// 拼接完整的请求
		String retn = STX + DATA + BCC;
		return retn;
	}

	public String getSTX() {
		return STX;
	}

	public void setSTX(String sTX) {
		STX = sTX;
	}

	public String getRSCTL() {
		return RSCTL;
	}

	public void setRSCTL(String rSCTL) {
		RSCTL = rSCTL;
	}

	public String getLength() {
		return Length;
	}

	public void setLength(String length) {
		Length = length;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getBroadening() {
		return broadening;
	}

	public void setBroadening(String broadening) {
		this.broadening = broadening;
	}

	public String getType() {
		return Type;
	}

	public void setType(String type) {
		Type = type;
	}

	public String getBCC() {
		return BCC;
	}

	public void setBCC(String bCC) {
		BCC = bCC;
	}
}
